#!/usr/bin/env bash

WEB_HOME="/www/web/meetting-room-web"
if [ -d ${WEB_HOME} ]
then
  echo "${WEB_HOME} exists, clean it"
  rm -f ${WEB_HOME}/index.html
  rm -rf ${WEB_HOME}/static
else
  echo "create directory ${WEB_HOME}"
  mkdir ${WEB_HOME}
fi

echo "Build production files into dist ..."
rm -rf dist
cnpm install
npm run build


echo "Copy dist files into $WEB_HOME"
cp dist/index.html ${WEB_HOME}/
cp -r dist/static ${WEB_HOME}/

chown -R www:www ${WEB_HOME}
